{extend name="base" /}
{block name="cont"}
<div class="row">
    <div class="col-xs-12">

        <div class="row">
            <div class="col-xs-12">
                <h3 class="header smaller  white ">
                    <i class="ace-icon fa fa-check green"></i><strong class="red">提醒：</strong>退款为官方实时退款接口，不能随便乱点</div>
                </h3>
                <div class="table-header">
                    超时订单管理
                </div>
                <div class="table-responsive">
                    <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>id</th>
                            <th>订单号</th>
                            <th>用户id</th>
                            <th>备注</th>
                            <th>下单人</th>
                            <th>下单电话</th>
                            <th>下单地址</th>
                            <th>状态</th>
                            <th>配送员姓名</th>
                            <th>配送员电话</th>
                            <th>下单时间</th>
                            <th>过期时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        {foreach $orders as $k=>$v}
                        <tr>
                            <td>{$v.order_id}</td>
                            <td>{$v.order_num}</td>
                            <td>{$v.user_id}</td>
                            <td>{$v.order_content}</td>
                            <td>{$v.user_name}</td>
                            <td>{$v.user_phone}</td>
                            <td>{$v.user_address}</td>
                            {if $v.order_status==1}
                            <td class="text-danger">未接单</td>
                            {elseif $v.order_status==2 /}
                            <td class="text-info">配送中</td>
                            {elseif $v.order_status==3 /}
                            <td class="text-success">完成</td>
                            {else /}
                            <td class="text-success">已退款</td>
                            {/if}
                            {if $v.tuple_msg}
                            <td class="text-success">{$v.tuple_msg.user_name}</td>
                            {else /}
                            <td class="text-danger">暂未接单</td>
                            {/if}
                            {if $v.tuple_msg}
                            <td class="text-success">{$v.tuple_msg.user_phone}</td>
                            {else /}
                            <td class="text-danger">暂未接单</td>
                            {/if}
                            <td>{:date('Y-m-d H:i:s',$v.order_ctime)}</td>
                            <td>{:date('Y-m-d H:i:s',$v.order_outtime)}</td>
                            <td>
                                {if $v.order_status==1 /}
                                <button class="btn btn-sm btn-danger" onclick="tuikuan({$v.order_num})">退款</button>
                                {elseif $v.order_status==4}
                                <button class="btn btn-sm btn-success">退款成功</button>
                                {/if}
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>


    </div><!-- /.col -->
</div>
<script>
    function tuikuan(order_num) {
        $.ajax({
            url: "{:url('order/tuikuan')}",
            type: "POST",
            data: {
                order_num:order_num
            },
            dataType: "json",
            success: function(res){
                if(res.status){
                    location.reload();
                }else {
                    alert(res.msg);
                }
            }
        });
    }
</script>
{/block}